{% extends "app/base_site.html" %}
{% block title %} {% if  "add" == handle %}添加{% else %}编辑{% endif %}节点 {% endblock title %}
{% block stylesheets %}
  {{ block.super }}
    <style>
    input[type="file"]{
      color: #8d2f2f;
      font-size: 12px;
    }
    ::file-selector-button{
      font-size: 12px;
      color: #fff;
      border-radius: 4px;
      border: 1px solid #2a80eb;
      padding: 2px 4px;
      background-color: #2a80eb;
      cursor: pointer;
    }

</style>
{% endblock stylesheets %}
{% block content %}

  <div class="right_col" role="main">
    <div class="">
      <div class="row">
        <div class="col-md-12 col-xs-12">
          <div class="x_panel">
            <div class="x_title">
                <h2>{% if  "add" == handle %}添加{% else %}编辑{% endif %}节点
                 <span id="top_msg">{{top_msg}}</span>
                </h2>

                <div class="clearfix"></div>
            </div>
            <div class="x_content">
              <br>
              <form class="form-horizontal form-label-left"  method="post" enctype="multipart/form-data" data-parsley-validate  >

                     <input type="hidden" name="handle"  value="{{ handle }}">
                     <input type="hidden" name="code"  value="{{ node.code }}">


                <div class="form-group">
                  <label class="control-label col-md-3 col-sm-3 col-xs-12">编号 <span class="required" style="color: red;">*</span></label>
                  <div class="col-md-6 col-sm-6 col-xs-12">
                     <input type="text"  value="{{ node.code }}" class="form-control" disabled="disabled">
                  </div>
                </div>


                <div class="form-group">
                  <label class="control-label col-md-3 col-sm-3 col-xs-12">序号 <span class="required" style="color: red;">*</span></label>
                  <div class="col-md-6 col-sm-6 col-xs-12">
                     <input type="number" name="sort"  value="{{ node.sort }}" class="form-control">
                  </div>
                </div>
               <div class="form-group">
                  <label class="control-label col-md-3 col-sm-3 col-xs-12">节点昵称 <span class="required" style="color: red;">*</span></label>
              <div class="col-md-6 col-sm-6 col-xs-12">
                    <input type="text" name="nickname" value="{{ node.nickname }}" required="required"  class="form-control">
                  </div>
                </div>
                             <div class="form-group">
                  <label class="control-label col-md-3 col-sm-3 col-xs-12">节点地址 <span class="required" style="color: red;">*</span></label>
              <div class="col-md-6 col-sm-6 col-xs-12">
                    <input type="text" name="address" value="{{ node.address }}" required="required"  class="form-control">
                  </div>
                </div>




                             <div class="form-group">
                  <label class="control-label col-md-3 col-sm-3 col-xs-12">xcms_safe <span class="required" style="color: red;">*</span></label>
              <div class="col-md-6 col-sm-6 col-xs-12">
                    <input type="text" name="xcms_safe" value="{{ node.xcms_safe }}" required="required"  class="form-control">
                  </div>
                </div>

                             <div class="form-group">
                  <label class="control-label col-md-3 col-sm-3 col-xs-12">media_secret <span class="required" style="color: red;">*</span></label>
              <div class="col-md-6 col-sm-6 col-xs-12">
                    <input type="text" name="media_secret" value="{{ node.media_secret }}" required="required"  class="form-control">
                  </div>
                </div>
 {% if  "edit" == handle %}



                 <div class="form-group">
                  <label class="control-label col-md-3 col-sm-3 col-xs-12">node_code </label>
              <div class="col-md-6 col-sm-6 col-xs-12">
                    {{ node.node_code }}
                  </div>
                </div>


             <div class="form-group">
                  <label class="control-label col-md-3 col-sm-3 col-xs-12">node_host </label>
              <div class="col-md-6 col-sm-6 col-xs-12">
                    {{ node.node_host }}
                  </div>
                </div>
                                 <div class="form-group">
                  <label class="control-label col-md-3 col-sm-3 col-xs-12">添加时间 </label>
              <div class="col-md-6 col-sm-6 col-xs-12">
                    {{ node.create_time }}
                  </div>
                </div>
                                                   <div class="form-group">
                  <label class="control-label col-md-3 col-sm-3 col-xs-12">更新时间 </label>
              <div class="col-md-6 col-sm-6 col-xs-12">
                    {{ node.last_update_time }}
                  </div>
                </div>
 {% endif %}



                <div class="form-group">
                  <div class="col-md-9 col-sm-9 col-xs-12 col-md-offset-3">
                    <button type="button" onclick="window.history.go(-1)" class="btn btn-default">返回</button>
                    <button type="submit" class="btn btn-dark">提交</button>

                  </div>
                </div>

              </form>
            </div>
          </div>
        </div>
      </div>

    </div>
  </div>
{% endblock content %}

{% block javascripts %}
  {{ block.super }}
<script>

let handle = "{{ handle }}";
let ele_input_name= $("input[name='name']");
$(document).ready(function () {
   $("form").submit(function () {
        if(ele_input_name.val().trim() === ""){
            myAlert("请输入名称","error");
            return false;
        }

       if("add" === handle){
            //添加

       }else {
            //更新

       }

   });
});
</script>

{% endblock javascripts %}
